import { useCallback } from "react"
import { useTranslation } from "react-i18next"
import { INIT_LANG } from '@/config'

const useLanguage = () => {
  const lang = window.Lstorage.get('language') || INIT_LANG
  const { i18n } = useTranslation()
  const changeLanguage = (code) => {
    window.Lstorage.set('language', code)
    i18n.changeLanguage(code)
  }
  return {
    initLang: lang,
    changeLanguage
  }
}

export default useLanguage